Get ID of incident after event creation

Hello everybody,
we have issues getting an asynchronous sync with the pager duty incidents running.
When our system throws an alert, we use the event API to create an event in PagerDuty which then in return notifies the Team. The event gets “grouped” into an incident within PagerDuty.
After some time, we want our system to add information to the existing incident later (for example in form of an incident note). All of the API requests to achieve this need the incident id.
My question is, how can I get the incident ID to an event which I created earlier. In a “perfect world” I would just get the incident ID back in the response when creating the event, but unfortunately thats not the case.

Any help on ways to achieve this is appreciated!
Thank you :slight_smile:

Benedict

Hi Benedict.

This is a two-step process. When an alert is ingested, it might not become an incident immediately (it might be suppressed or it might go through some rules), so the return to the alerting system is just an acknowledgement and the dedup key rather than including an incident ID.

You can use that dedup_key to get the incident via another query. The /incidents endpoint has an incident_key option that you can append:

https://api.pagerduty.com/incidents?incident_key={$DEDUP_KEY}.

The return from that query will be the incident that includes alerts with that dedup_key. You’ll find the ID you need as the id in that json body.

Hope that helps!

–mandi

2 Likes

Hi Mandi,
thanks a lot! That helped, I wasn’t able to find that API call in your reference.
We’re now able to append a note to an existing incident.
Another question which is now coming up: Is there any way to append html formatted information to an incident?
Looking at the “Update an Alert” API, I only see the “details” part of the body with the “CustomKey field” which looks promising. But I’m not able to find this field in the app or the WebGUI.

Thank you in advance!
Regards
Benedict

Hi!

There’s a couple of things you might want to look at. Updating the alert itself is probably not the most helpful thing once an alert is associated with an incident, but the incident object has a couple of other structures that you can add more information to.

One is the notes feature. You can update these via the API as well. These notes don’t send an update to stakeholders. They appear in the UI for folks to reference.

Another option is status updates. These will send a notification to stakeholders. They can be created in the UI, the mobile app, and the API.

Either one of those might be helpful for you!